package com.rg.servlet;

import com.rg.model.GoodsModel;
import com.rg.service.GoodsService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/GoodsMenu")
public class GoodsMenu extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request,response);
    }
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("UTF-8");
        response.setCharacterEncoding("UTF-8");
        int typeid = Integer.parseInt(request.getParameter("typeId"));
        GoodsService goodsService = new GoodsService();
        List<GoodsModel> menuGoodslist = goodsService.selectMenuGoodsByType(typeid);
        request.setAttribute("menuGoodslist", menuGoodslist);
        request.getRequestDispatcher("goodsMenu.jsp").forward(request, response);
    }
}
